package com.pig4cloud.pig.environment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.environment.entity.EquipmentEntity;
import com.pig4cloud.pig.environment.mapper.EquipmentMapper;
import com.pig4cloud.pig.environment.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 设备管理
 *
 * @author joyql
 * @date 2024-01-12 16:38:03
 */
@Service
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, EquipmentEntity> implements EquipmentService {
	@Autowired
	private EquipmentMapper equipmentMapper;
	@Override
	public Map<Long, String> getNamesByIds(List<Long> ids) {
		QueryWrapper<EquipmentEntity> queryWrapper=new QueryWrapper<>();
		queryWrapper.select("id","name").in("id",ids);
		return ids.size()>0?equipmentMapper.selectList(queryWrapper).stream().collect(Collectors.toMap(EquipmentEntity::getId,EquipmentEntity::getName)):null;
	}
}